<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>姓名案例_methods实现</title>
    <script src="../js/vue.js"></script>
  </head>
  <body>
    <div id="root">
      姓：<input type="text" v-model="firstName" /><br />
      名：<input type="text" v-model="lastName" /><br />
      姓名：<span>{{fullName()}}</span><br />
      姓名：<span>{{fullName()}}</span><br />
      姓名：<span>{{fullName()}}</span>
    </div>
  </body>
  <script>
    Vue.config.productionTip = false;

    new Vue({
      el: "#root",
      data: {
        firstName: "张", // 任何一个属性的改变都会引起Vue模板的重新解析
        lastName: "三",
      },
      methods: {
        fullName() {
          console.log("---------fullName---------");
          return this.firstName + "-" + this.lastName;
        },
      },
    });
  </script>
</html>
